/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package df.bean.db;

import java.util.Vector;
/**
 *
 * @author Pong
 */
public class DataRecord {

    protected String table;
    protected Vector<DataField> fields;
    
    public DataRecord() {
        this(null);
    }
    
    public DataRecord(String table) {
        this.table = table;
        this.fields = new Vector<DataField>();
    }
    
    public boolean addField(String field, int type, String value) {
        return this.addField(field, type, value, false);
    }
    
    public boolean addField(String field, int type, String value, boolean pk) {
        return DBMgr.isValidType(type) ? fields.add(new DataField(field, type, value, pk)) : false;
    }
    
    public DataField getField(String field) {
        int size = fields.size();
        for (int i = 0; i < size; i++) {
            if (fields.elementAt(i).name.equalsIgnoreCase(field)) {
                return fields.elementAt(i);
            }
        }
        return new DataField();
    }
}
